package com.tianpengtech.front.web.feedback;

import com.tianpengtech.common.exception.ValidateException;
import com.tianpengtech.common.model.feedback.FeedBack;
import com.tianpengtech.common.model.user.User;
import com.tianpengtech.common.util.JsonUtil;
import com.tianpengtech.front.web.common.controller.BaseController;
import com.tianpengtech.front.web.login.LoginService;

/**
 *
 * @author ggd
 */
// @Clear(PassportInterceptor.class)
public class FeedBackWebController extends BaseController {
	private FeedBackService service = new FeedBackService();

	/**
	 * 反馈
	 */
	public void index() {
		renderTemplate("feedback.html");
	}

	public void success() {
		renderTemplate("feedback_success.html");
	}

	public void doFeedBack() {
		try {
			FeedBack feedBack = getModel(FeedBack.class, "feedback");
			User user = getAttr(LoginService.loginAccountCacheName);
			feedBack.set(FeedBack.USER, user.get(User.ID));
			service.save(feedBack);
			renderJson(JsonUtil.printSuccess("反馈成功"));
		} catch (ValidateException e) {
			renderJson(JsonUtil.printError(e.getMessage()));
		}
	}
}
